﻿using IntelligentGateway.Services;
using IntelligentGateway.SmartCommunity.Server;
using Microsoft.AspNetCore.Hosting.Server;

namespace IntelligentGateway.Extension
{
    public static class ApplicationBuilderExtensions
    {
        public static IApplicationBuilder UseAiliftServer(this IApplicationBuilder app, Action<IServer> configure)
        {
            var server = app.ApplicationServices.GetRequiredService<IServer>();
            return app;
        }
         public static IApplicationBuilder UseIGWebSocketClient(this IApplicationBuilder app)
        {
            IntelligentGatewayServices.StartIGWebSocketClient();
            return app;
        }
        public static IApplicationBuilder UseTPWebSocketServer(this IApplicationBuilder app)
        {
            IntelligentGatewayServices.StartTPWebSocketServer();
            return app;
        }
        public static IApplicationBuilder UseSerialPort(this IApplicationBuilder app)
        {
            IntelligentGatewayServices.StartSerialPort();
            return app;
        }
        //public static IApplicationBuilder UseIGTCPClient(this IApplicationBuilder app)
        //{
        //    IntelligentGatewayServices.StartIGTCPClient();
        //    return app;
        //}
        public static IApplicationBuilder UseIGTCPServer(this IApplicationBuilder app)
        {
            IntelligentGatewayServices.StartIGTCPServer();
            return app;
        }
        public static IApplicationBuilder UseCheckHearBeat(this IApplicationBuilder app)
        {
            IntelligentGatewayServices.StartHeartBeat();
            return app;
        }

        public static IApplicationBuilder UseDeviceServer(this IApplicationBuilder app)
        {
            var server = app.ApplicationServices.GetRequiredService<DeviceServer>();

            return app;
        }
        public static IApplicationBuilder UseCheckLog(this IApplicationBuilder app)
        {
            LogTask.StartDeleteLog();
            return app;
        }
    }
}
